package com.im.dao;


import com.im.domain.bean.TextMessage;
import com.im.domain.enumtype.MessageType;
import com.im.domain.enumtype.SendType;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 *
 */
@Repository
public interface TextMessageRepository extends JpaRepository<TextMessage, String>,JpaSpecificationExecutor<TextMessage>{
	
	@Query("select tm from TextMessage tm where sendId=:sendId and sendType=:sendType and "
			+ "type=:type ")
	public List<TextMessage> getListByParam(@Param("sendId")String sendId,
			@Param("sendType")SendType sendType,@Param("type")MessageType type);
	
	@Query("delete TextMessage tm where tm.timeStamp < :time")
	public void deleteDataByTime(@Param("time")Date time);
	
}
